Declaration of global variables in global-object and its usage in ST
The declaration of →global variables in a global-object allows you to collect the declaration of global variables in one or more central objects for the project. Subsequently, you just insert a reference where you will need the declaration – this will be a →program, →resource or →configuration.
Enhancement to IEC-standard This possibility is an enhancement to the →IEC-standard. |
Neuron Power Engineer offers the global-variables-editor as an alternative to display and edit global variables within a global-object. Moreover, the application navigator provides a possibility to automatically insert the reference (details: see "Creating and using a global-object"). In both cases, you do not need to know the following syntax.
Creating global-object
See "Creating and using a global-object".
GLOBALS section in global-object for central declaration of global variables
Declare the global variables within the GLOBALS
section of a global-object, do this analogous to the declaration of global variables in ST. One GLOBALS
section is possible per global-object.
Syntax |
---|
|
Meaning |
---|
declaration of the As already indicated, the syntax for
Moreover, observe: If you specify a namespace within the global-object, this namespace has no impact onto the access to such global variables by using the appertaining →external variable. Because the access is done via the name of the variable. Hence, no fully qualified name and no additional |
Good to know |
---|
Moreover, Neuron Power Engineer allows you to define a not yet fully specified location for the declaration. See "Declaration of a language element with partial address in ST" for details. Moreover, Neuron Power Engineer allows you to specify additional data for the declaration. See "Defining description, comment, JSON string or type for variables or data types" for details. |
Example |
---|
|
Reference to the GLOBALS section in a program, resource and/or configuration
In the program, the resource or the configuration, insert INCLUDE_GLOBALS
directives so that the global variables from the corresponding GLOBALS
section are declared as program-global, resource-global or configuration-global variables.
If the GLOBALS
section is declared within a namespace, specify the fully qualified name. A fully qualified name consists of a sequence of namespace identifiers separated by .
(dots).
Syntax |
---|
|
Always insert the INCLUDE_GLOBALS
directives in front of possibly existing sections VAR_GLOBAL ... END_VAR
.
Example for a reference in a program |
---|
|
For the reference in a resource, it is indispensable to insert the INCLUDE_GLOBALS
directive before the tasks are declared:
Example for a reference in a resource |
---|
|
Example for a reference in a configuration |
---|
|